<?php

namespace Itwmw\Attributes\Validate\Rules;

/**
 * 当你需要多个规则中只要有一个通过即可时，可以使用 or 规则
 *
 * @see https://v.itwmw.com/5/Rule.html#or%E8%A7%84%E5%88%99
 */
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
class OrRule implements RuleInterface
{
    protected array $args = [];

    /** @var array<RuleInterface|class-string<RuleInterface>> */
    public readonly array $subRules;

    /**+
     * @param RuleInterface|class-string<RuleInterface> ...$subRules
     */
    public function __construct(...$subRules)
    {
        $this->args     = func_get_args();
        $this->subRules = $subRules;
    }

    public function getArgs(): array
    {
        return $this->args;
    }
}
